package cn.fboost.mtos.controller;

import cn.fboost.mtos.annotation.IgnoreTokenCheck;
import cn.fboost.mtos.service.CallbackService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 回调控制器
 */
@IgnoreTokenCheck
@RestController
@RequestMapping("callback")
public class CallbackController {
    private final CallbackService callbackService;

    public CallbackController(CallbackService callbackService) {
        this.callbackService = callbackService;
    }

    @PostMapping("wechat/pay")
    public String wechatPayCallback(@RequestBody String body, HttpServletRequest request, HttpServletResponse response) {
        return callbackService.wechatPayCallback(body, request, response);
    }
}
